{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 时间：2022-10-25/week10\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "\n",
    "> 1.while循环：while True--无限循环    \n",
    ">> A.指定次数，while True可以实现for循环的指定次数，增加一个count计算器即可   \n",
    ">> B.while True一般与“用户输入”一起使用，让用户可以重复输入，周到某些条件成立结束输入（购物车）   \n",
    "> 2. 购物车"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "\n",
    "> 1.元组   \n",
    "> 2.集合   \n",
    "> 3.字典   "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.元组（tuple)\n",
    "\n",
    "> 1.元组的基本内容（形态、定义）\n",
    "> 2. 元组的性质\n",
    ">> 1.有序性（indexing，sliceing)  \n",
    ">> 2.<font color=\"red\">**不可变性**</font>\n",
    "\n",
    "> 3,元组的一般办法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1800001, 1800002, 1800003) <class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "网三_学号 = (1800001,1800002,1800003)\n",
    "print(网三_学号,type(网三_学号))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1900001, 1900002, 1900003) <class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "网二_学号 = (1900001,1900002,1900003)\n",
    "print(网二_学号,type(网二_学号))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1900001"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_学号[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1900002, 1900003)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_学号[1:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "([1, 2, 3, 4], [3, 4, 5, 6]) <class 'tuple'> 2277976196104\n",
      "([1, 2, 3, 4], [3, 4, 5, 6]) 2277976196104\n"
     ]
    }
   ],
   "source": [
    "tuple_test =([1,2,3,4],[3,4,5,6])\n",
    "print(tuple_test,type(tuple_test),id(tuple_test))\n",
    "print(tuple_test,id(tuple_test))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "tuple_test[0].append(100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([1, 2, 3, 4, 100, 100], [3, 4, 5, 6])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tuple_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "([1, 2, 3, 4], [3, 4, 5, 6]) <class 'tuple'> 2277976196104\n",
      "([1, 2, 3, 4], [3, 4, 5, 6]) 2277976196104\n"
     ]
    }
   ],
   "source": [
    "print(tuple_test,type(tuple_test),id(tuple_test))\n",
    "print(tuple_test,id(tuple_test))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 一般情况下，元组里面存放的是 常量（不可变），何为常量；数字，字符串\n",
    "#  不存放变量 如：列表，字典"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.集合（sets)\n",
    "\n",
    "> 1. 集合的基本概念\n",
    ">> 1. 性质：没有重复项（去重性）\n",
    ">> 2. 性质；无序性\n",
    "> 2. 集合的一般方法\n",
    ">> 1.集合的运算\n",
    ">> 2.集合的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['apple', 'orange', 'apple', 'pear', 'orange', 'banana']\n",
      "{'apple', 'orange', 'banana', 'pear'}\n"
     ]
    }
   ],
   "source": [
    "besket_lists =['apple','orange','apple','pear','orange','banana' ]\n",
    "besket_sets ={'apple','orange','apple','pear','orange','banana' }\n",
    "print(besket_lists)\n",
    "print(besket_sets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "丽影舞蹈队 = {2101,2102,2107,2109,2110}\n",
    "魅声歌唱队 = {2100,2103,2104,2108,2110}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 集合的运算，交集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2110}"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "丽影舞蹈队 & 魅声歌唱队"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2110}"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "丽影舞蹈队.intersection(魅声歌唱队)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 集合的运算，并集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2100, 2101, 2102, 2103, 2104, 2107, 2108, 2109, 2110}"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "丽影舞蹈队 | 魅声歌唱队"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(丽影舞蹈队 | 魅声歌唱队)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2100, 2101, 2102, 2103, 2104, 2107, 2108, 2109, 2110}"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "丽影舞蹈队.union(魅声歌唱队)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.字典（dict)\n",
    "\n",
    "> 1. 字典的基本概念   \n",
    ">> 1.字典性质   \n",
    ">>> 1.无序性\n",
    ">>> 2.keys 是不可变的\n",
    ">>> 3.keys 是唯一的\n",
    ">> 2. 字典的形态"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
